import JSEncrypt from "jsencrypt";

export default {
  encodeRSA(word, keyStr) {
    console.log(word)
    //这个是公钥,有入参时用入参，没有入参用默认公钥
    keyStr = keyStr ? keyStr : 'University car system';
    //创建对象
    let jsRsa = new JSEncrypt();
    //设置公钥
    jsRsa.setPublicKey(keyStr);
    console.log("在密码加密这里")
    console.log(jsRsa)
    console.log(jsRsa.encrypt(word))
    //返回加密后结果
    let rsaPassword = jsRsa.encrypt(word)
    console.log(btoa(rsaPassword))
    return jsRsa.encrypt(word);
  }

}
